<template>
    <div class="app-container">
        <el-descriptions v-if="form.escort" class="borderBlock table" title="订单基本信息" :column="4"  border>
            <el-descriptions-item>
                <template slot="label">
                    订单编号
                </template>
                {{form.escort.escort_order_sn}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <div class="question">订单应支付金额<i class="headerIcon el-icon-question" @click="dialogShow(1)"></i></div>
                </template>
                {{form.escort.payable_amount?form.escort.payable_amount.toFixed(2):'0.00'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <div class="question">最终优惠金额</div>
                </template>
                <span>{{Number(form.escort.amount).toFixed(2)}}</span>
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    所在医院
                </template>
                {{form.escort.hospital_name}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    订单状态
                </template>
                {{typeName(form.escort)}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <div class="question">订单金额（元）<i class="headerIcon el-icon-question" @click="dialogShow(2)"></i></div>
                </template>
                {{form.escort.pay_amount?Number(form.escort.pay_amount).toFixed(2):'0.00'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    平台补贴金额
                </template>
                {{form.carried_forward_income?form.carried_forward_income.amount.toFixed(2):''}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    所在科室
                </template>
                {{form.escort.inpatient_area_name}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    服务类型
                </template>
                {{form.escort.nursing_service.name}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <div class="question">支付时优惠金额<i class="headerIcon el-icon-question" @click="dialogShow(3)"></i></div>
                </template>
                <span style="color:#f59a23; font-weight: bold;">{{Number(form.escort.amount).toFixed(2)}}</span>
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    订单备注
                </template>
                {{form.escort.notes}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    服务开始时间
                </template>
                {{parseTime(form.escort.start_time)}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <div class="question">患者支付金额<i class="headerIcon el-icon-question" @click="dialogShow(4)"></i></div>
                </template>
                {{form.escort.pay_amount?Number(form.escort.pay_amount).toFixed(2):'0.00'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    付款方式
                </template>
                {{paymentName(form.escort.payment,form.escort.type)}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    订单创建时间
                </template>
                {{parseTime(form.escort.create_time)}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    服务截止时间
                </template>
                {{parseTime(form.escort.estimate_end_time)}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <div class="question">退款金额<i class="headerIcon el-icon-question" @click="dialogShow(5)"></i></div>
                </template>
                -{{relationOrder.pay?relationOrder.pay.refund_amount.toFixed(2):'0.00'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    支付类型
                </template>
                {{escortTypeName(form.escort.type)}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    订单付款时间
                </template>
                {{form.escort.pay_time?parseTime(form.escort.pay_time):' - - '}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    订单预缴天数
                </template>
                {{form.escort.estimate_day}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <div class="question">返还优惠券金额<i class="headerIcon el-icon-question" @click="dialogShow(6)"></i></div>
                </template>
                {{form.escort.pay_amount?Number(form.escort.pay_amount).toFixed(2):'0.00'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    订单类型
                </template>
                {{escortTypeName(form.escort.type)}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    订单完成时间
                </template>
                {{form.escort.end_time?parseTime(form.escort.end_time):' - -  '}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    订单服务单价
                </template>
                {{form.escort.price?form.escort.price.toFixed(2):''}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    结转支出金额
                </template>
                -{{form.carried_forward?form.carried_forward.amount.toFixed(2):'0.00'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    项目主管姓名
                </template>
                {{form.admin.truename}}
            </el-descriptions-item>
            <el-descriptions-item><template slot="label"></template></el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    结转收入金额
                </template>
                {{form.carried_forward?form.carried_forward.amount.toFixed(2):'0.00'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <div class="question">订单实缴金额<i class="headerIcon el-icon-question" @click="dialogShow(7)"></i></div>
                </template>
                <span style="color:#f59a23; font-weight: bold;">{{Number(form.escort.amount).toFixed(2)}}</span>
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    项目主管手机号
                </template>
                {{form.admin.mobile}}
            </el-descriptions-item>


        </el-descriptions>

        <div class="operationRecord borderBlock ">
            <div class="title">护工分配记录：</div>
            <el-descriptions v-for="item in nursingWorkerList" :key="item.id" class="margin-top tableNoW" :column="7"  border>
                <el-descriptions-item >
                    <template slot="label">
                        护工姓名
                    </template>
                    {{item.user.truename?item.user.truename:' - - '}} | {{item.user.mobile?item.user.mobile:' - - '}}
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        上活时间
                    </template>
                    {{item.start_time?parseTime(item.start_time):' - - '}}
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        下活时间
                    </template>
                    {{item.estimate_end_time?parseTime(item.estimate_end_time):' - - '}}
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        护工服务天数
                    </template>
                    {{item.estimate_day}}
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        护工服务单价
                    </template>
                    {{item.price==0?'0.00':item.price.toFixed(2)}}
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        <div class="question">主管录入护理服务费<i class="headerIcon el-icon-question" @click="dialogShow(8)"></i></div>
                    </template>
                    {{item.paid_amount==0?'0.00':item.paid_amount.toFixed(2)}}
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        上活状态
                    </template>
                    {{workType(item.status)}}
                    <a target="_blank" title="查看合同" :href="item.contract_url" v-if="item.contract_url">
                        <div class="agreement" :style="regenerateNursingWorkerContractStyle?'right:25px':'right:-10px'" ></div>
                    </a>
                    <div  title="重新生成合同" v-hasPermi="['regenerateNursingWorkerContract']" class="generate" @click="regenerateNursingWorkerContract(item.id)" ></div>
                </el-descriptions-item>
            </el-descriptions>

        </div>

        <div class="operationRecord borderBlock" >
            <div class="title">护工劳务费结算记录</div>
            <div class="carerList">
                <el-table
                        ref="singleTable"
                        :data="nursingWorkerList"
                        :show-header="false"
                        highlight-current-row
                        style="width: 100%">
                    <el-table-column>
                        <template slot-scope="scope">
                            <div class="carerTitle">
                                <span>护工：{{scope.row.user.truename}}</span><span class="line">|</span>
                                <span>待申请金额：¥ {{Number(scope.row.wait_apply_amount).toFixed(2)}}（护理服务费：¥ {{Number(scope.row.surplus_amount).toFixed(2)}},  奖励金额：¥{{Number(scope.row.reward_amount).toFixed(2)}}，处罚金额：¥-{{Number(scope.row.punishment_amount).toFixed(2)}}）</span><span class="line">|</span>
                                <span>审核中金额：¥ {{Number(scope.row.wait_examine_amount).toFixed(2)}} </span><span class="line">|</span>
                                <span>待发放金额：¥ {{Number(scope.row.wait_distribute_amount).toFixed(2)}} </span><span class="line">|</span>
                                <span>已发放金额：¥ {{Number(scope.row.distribute_amount).toFixed(2)}}</span><span class="line">|</span>
                            </div>
                            <el-descriptions v-for="item in scope.row.salary" :key="item.id" class="margin-top" :column="4"  border>
                                <el-descriptions-item >
                                    <template slot="label">
                                        结算编号
                                    </template>
                                    <router-link style="color: #498aff;" target="_blank" :to="'/nursingworkersalary/nursingworkersalaryinfo?id=' + item.id" >{{item.salary_sn}}</router-link>
                                </el-descriptions-item>
                                <el-descriptions-item >
                                    <template slot="label">
                                        护工姓名
                                    </template>
                                    {{scope.row.user.truename}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                    <template slot="label">
                                        护理服务费（元）
                                    </template>
                                    {{Number(item.nursing_amount).toFixed(2)}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                    <template slot="label">
                                        处罚金额
                                    </template>
                                    - {{Number(item.punishment_amount).toFixed(2)}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                    <template slot="label">
                                        结算状态
                                    </template>
                                    {{salary_statusName(item.salary_status)}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                    <template slot="label">
                                        护工劳务费
                                    </template>
                                    {{Number(item.amount).toFixed(2)}}
                                </el-descriptions-item>
                                <el-descriptions-item >
                                    <template slot="label">
                                        奖励金额
                                    </template>
                                    {{Number(item.reward_amount).toFixed(2)}}
                                </el-descriptions-item>





                            </el-descriptions>
                        </template>
                    </el-table-column>
                </el-table>


            </div>

        </div>
        <div>
            <el-descriptions class="borderBlock table" title="优惠金额" :column="4"  border>
                <el-descriptions-item >
                    <template slot="label">
                        优惠券流水号
                    </template>
                    YH2023082000100001
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        优惠券面值
                    </template>
                    150.00
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        优惠券名称
                    </template>
                    平台10周年补贴
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        使用条件
                    </template>
                    满300减100
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        发券方
                    </template>
                    企业
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        优惠券发放对象
                    </template>
                    企业员工
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        有效期
                    </template>
                    2022/03/01 10:00-2022/12/31 10:00
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        适用场景
                    </template>
                    一对一陪护、监护室大护
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        退款进度
                    </template>
                    退款完成
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        退款原因
                    </template>
                    陪护提前结束
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        退款申请时间
                    </template>
                    2022/03/15 13:20:20
                </el-descriptions-item>
                <el-descriptions-item >
                    <template slot="label">
                        退款完成时间
                    </template>
                    2022/03/15 14:20:20
                </el-descriptions-item>
            </el-descriptions>
        </div>
        <el-descriptions  v-if="relationOrder.pay&&relationOrder.pay.out_trade_no&&relationOrder.pay.pay_status>1" class="borderBlock table" title="退款信息" :column="4"  border>
            <el-descriptions-item >
                <template slot="label">
                    退款编号
                </template>
                {{relationOrder.pay.out_trade_no=='TK'?'- -':relationOrder.pay.out_trade_no}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    退款方式
                </template>
                {{refundMode(relationOrder.pay.payment)}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    退款申请时间
                </template>
                {{parseTime(relationOrder.pay.apply_refund_time)}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    退款原因
                </template>
                {{refundReason(relationOrder.pay.refund_reason_type)}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    退款金额
                </template>
                {{relationOrder.pay?relationOrder.pay.refund_amount.toFixed(2):'0.00'}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    退款进度
                </template>
                {{refundRate(relationOrder.pay.pay_status)}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    退款更新时间
                </template>
                {{parseTime(relationOrder.pay.refund_time)}}

            </el-descriptions-item>
        </el-descriptions>

        <el-descriptions v-if="form.patient" class="borderBlock table" title="患者信息" :column="4"  border>
            <template slot="extra">
                <el-button  v-hasPermi="['updatePatientName']" @click="updateEscortInfo" type="primary" size="mini">保存</el-button>
            </template>
            <el-descriptions-item>
                <template slot="label">
                    患者ID
                </template>
                {{form.escort.user_id?form.escort.user_id:''}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    身份证号码
                </template>
                {{form.patient.idcard}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    所在医院
                </template>
                {{form.escort.hospital_name}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    与陪护方关系
                </template>
                {{form.patient.accompanying_party?form.patient.accompanying_party:' - -'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    患者姓名
                </template>

                <el-input
                        placeholder="请输入姓名"
                        v-model="form.patient.truename"
                        v-if="updatePatientName"
                        clearable>
                </el-input>
                <div v-else>{{form.patient.truename}}</div>
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">
                    性别
                </template>
                {{form.patient.gender==1?"男":'女'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    所在病区
                </template>
                {{form.escort.inpatient_area_name}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    陪护方姓名
                </template>
                {{form.patient.accompanying_party_name?form.patient.accompanying_party_name:' - -'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    患者/家属手机号码
                </template>
                {{form.patient.mobile}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    年龄
                </template>
                {{form.patient.age?form.patient.age:''}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    所在床号
                </template>
                {{form.escort.bed_number}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    陪护方身份证号码
                </template>
                {{form.patient.accompanying_party_idcard?form.patient.accompanying_party_idcard:' - -'}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    患者绑定订单手机号
                </template>
                {{form.patient.bind_mobile}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    企业名称
                </template>
                平安健康管理有限公司
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    员工类型
                </template>
                普通员工
            </el-descriptions-item>
        </el-descriptions>

        <el-descriptions v-if="form.agreement_url" class="margin-top borderBlock table" title="电子合同" :column="4"  border>
            <el-descriptions-item>
                <template slot="label">
                    合同签署时间
                </template>
                {{form.sign_time?parseTime(form.sign_time):' - - '}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    电子合同
                </template>
                <a target="_blank" :href="form.agreement_url">
                    <el-button size="mini" type="primary" >查看</el-button>
                </a>
                <el-button  v-hasPermi="['regenerateContract']" style="margin-left: 10px;" size="mini" type="warning" @click="regenerateContract" >重新生成</el-button>
            </el-descriptions-item>
        </el-descriptions>

        <el-descriptions  v-if="relationOrder.extensionPeriodEscort&&relationOrder.extensionPeriodEscort.escort_order_sn" class="borderBlock table" title="展期详情" :column="4"  border>
            <el-descriptions-item >
                <template slot="label">
                    展期后订单编号
                </template>
                <router-link style="color: #498aff;" target="_blank" :to="{name:'OrderEscortInfo', query: {id:relationOrder.extensionPeriodEscort.escort_id}}">{{relationOrder.extensionPeriodEscort.escort_order_sn}}</router-link>
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    展期申请时间
                </template>
                {{parseTime(relationOrder.extensionPeriodEscort.create_time)}}
            </el-descriptions-item>

        </el-descriptions>

        <el-descriptions  v-if="relationOrder.finishTurnEscort&&relationOrder.finishTurnEscort.escort_order_sn" class="borderBlock table" title="转科详情" :column="4"  border>
            <el-descriptions-item >
                <template slot="label">
                    转科后订单编号
                </template>
                <router-link  style="color: #498aff;" target="_blank" :to="{name:'OrderEscortInfo', query: {id:finishTurnEscortEscortId}}">{{relationOrder.finishTurnEscort.escort_order_sn}}</router-link>
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    转科进度
                </template>
                {{extension_status_name(relationOrder.finishTurnEscort.extension_status)}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    转科后病区
                </template>
                {{relationOrder.finishTurnEscort.inpatient_area_name}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    转科发起时间
                </template>
                {{parseTime(relationOrder.finishTurnEscort.create_time)}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    转科后项目主管
                </template>
                {{relationOrder.finishTurnEscort.admin.truename}} | {{relationOrder.finishTurnEscort.admin.mobile}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    转科后医院
                </template>
                {{relationOrder.finishTurnEscort.hospital_name}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    转科后床位
                </template>
                {{relationOrder.finishTurnEscort.bed_number}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    转科更新时间
                </template>
                {{parseTime(relationOrder.finishTurnEscort.update_time)}}
            </el-descriptions-item>
            <el-descriptions-item >
                <template slot="label">
                    结转金额
                </template>
                {{relationOrder.finishTurnEscort.finish_turn_amount}}
            </el-descriptions-item>
        </el-descriptions>


        <div class="borderBlock allRelationOrder" v-if="relationOrder.relationOrder&&relationOrder.relationOrder.length>0">
            <div class="title">全部关联订单</div>
            <div class="list">
        <span v-for="item in relationOrder.relationOrder" :key="item.escort_id" >
          <router-link target="_blank" :to="{name:'OrderEscortInfo', query: {id:item.escort_id}}">{{item.escort_order_sn}}</router-link>
        </span>
            </div>
        </div>

        <div class="borderBlock operationJournal">
            <div class="title">陪护订单操作日志</div>
            <el-table
                    ref="singleTable"
                    :data="tableData"
                    highlight-current-row
                    style="width: 100%">
                <el-table-column
                        label="序号"
                        type="index"
                        align="center"
                        width="50">
                </el-table-column>
                <el-table-column
                        prop="escort_status"
                        label="系统日志"
                        width="150">
                </el-table-column>
                <el-table-column
                        prop="msg"
                        label="日志信息">
                </el-table-column>
                <el-table-column
                        prop="name"
                        label="操作人"
                        width="150">
                </el-table-column>
                <el-table-column
                        prop="create_time"
                        label="操作时间"
                        width="150">
                    <template slot-scope="scope">
                        {{parseTime(scope.row.create_time)}}
                    </template>
                </el-table-column>
            </el-table>
            <div class="page">
                <pagination
                        v-show="total > 0"
                        :total="total"
                        :page.sync="queryParams.page"
                        :limit.sync="queryParams.limit"
                        @pagination="getList"
                >
                </pagination>
            </div>
        </div>

        <el-dialog
                :title="dialogTitle"
                :visible.sync="dialogTips"
                width="575px"
                :before-close="handleClose">

            <div class="dialogTips" v-if="dialogType==1" >
                <div>“订单应支付金额”=订单服务单价*订单预缴天数-结转收入金额</div>
            </div>
            <div class="dialogTips" v-if="dialogType==2" >
                <div>“订单金额”=主管创建订单时录入的患者应支付金额</div>
            </div>
            <div class="dialogTips" v-if="dialogType==3" >
                <div>“支付时优惠金额”是指患者支付时选择的优惠券面值金额总和</div>
            </div>
            <div class="dialogTips" v-if="dialogType==4" >
                <div>“患者支付金额”等于该笔订单患者通过线上/线下两种支付方式实际支付的金额（不包含结转收入金额）</div>
            </div>
            <div class="dialogTips" v-if="dialogType==5" >
                <div>“退款金额”等于该笔订单患者实际退款的金额</div>
            </div>
            <div class="dialogTips" v-if="dialogType==6" >
                <div>“返还优惠金额”是指发生退款返还的优惠券金额</div>
            </div>
            <div class="dialogTips" v-if="dialogType==7" >
                <div>“订单实缴金额”为该笔订单的实际收入</div>
                <br />
                <div>订单实缴金额=患者支付金额+结转收入金额-退款金额-结转支出金额</div>
            </div>
            <div class="dialogTips" v-if="dialogType==8" >
                <div>该金额为主管手动录入的护工护理服务费总金额，原则上，应支付护理服务费=主管录入护理服务费；</div>
                <br />
                <div>特殊情况下，比如后续服务中护工服务单价增加或者减少，但是主管不方便修改护工单价的前提下，主管可能会修改护工护理服务费总金额，导致两个金额不相等。</div>
            </div>
        </el-dialog>

        <el-dialog
                title="护工详情"
                :visible.sync="centerDialogVisible"
                width="50%"
                center>
            <el-descriptions  :column="2"  border>
                <el-descriptions-item>
                    <template slot="label">
                        护工姓名
                    </template>
                    任嘉伦
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        护工服务时间（天）
                    </template>
                    10
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        护工手机号
                    </template>
                    18599999999
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        服务费单价（元）
                    </template>
                    180
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        护工分配时间
                    </template>
                    2022/03/10  20:10:30
                </el-descriptions-item>

                <el-descriptions-item>
                    <template slot="label">
                        应支付费用（元）
                    </template>
                    1,800
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        预计上活时间
                    </template>
                    2022/03/10  22:00
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        实际支付费用（元）
                    </template>
                    1,000
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        预计下活时间
                    </template>
                    2022/03/20  20:30
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        护工下活后状态
                    </template>
                    请假   |   2022/05/20 返岗
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        实际下活时间
                    </template>
                    2022/03/20  20:30
                </el-descriptions-item>

            </el-descriptions>
            <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="centerDialogVisible = false">关 闭</el-button>
      </span>
        </el-dialog>

    </div>
</template>

<script>
    import { checkPermi } from "@/utils/permission";
    import {orderEscortShow,orderEscortRelationOrder,orderEscortOptionLog,escortUpdateEscortInfo,regenerateContract,regenerateNursingWorkerContract} from "@/api/admin/product";

    export default {

        data() {
            return {
                centerDialogVisible:false,
                active: 0,
                form:{},
                relationOrder:{},
                currentRow: null,
                tableData:[],
                total:0,
                queryParams: {
                    page: 1,
                    limit: 10,
                    escort_id:'',
                },
                nursingWorkerList:[],
                finishTurnEscortEscortId:'',

                //提示
                dialogTitle:'',
                dialogTips:false,
                dialogType:'',

                //护工合同权限
                regenerateNursingWorkerContractStyle:false,
                //修改患者姓名权限
                updatePatientName:false
            };
        },
        watch: {},
        methods: {
            workType(type){
                var arr=[
                    "已取消",
                    "上活中",
                    "待上活",
                    "已完成",
                ]
                return arr[type]
            },
            setCurrent(row) {
                this.$refs.singleTable.setCurrentRow(row);
            },
            handleCurrentChange(val) {
                this.currentRow = val;
            },
            init: function () {
                this.getList();
                var escort_id = this.$route.query.id;
                orderEscortShow({ escort_id: escort_id }).then((response) => {
                    if (response.code == 200) {
                        this.form = response.data;
                        this.nursingWorkerList = response.data.nursingWorkerList
                    } else {
                        this.$message.error(response.msg);
                    }
                }).catch((error) => {
                    this.$message.error("请刷新页面");
                });
                orderEscortRelationOrder({ escort_id: escort_id }).then((response) => {
                    if (response.code == 200) {
                        this.relationOrder = response.data;
                        if(response.data.finishTurnEscort.escort_order_sn){
                            response.data.relationOrder.forEach(element => {
                                if(element.escort_order_sn == response.data.finishTurnEscort.escort_order_sn){
                                    this.finishTurnEscortEscortId = element.escort_id
                                }
                            });
                        }
                    } else {
                        this.$message.error(response.msg);
                    }
                }).catch((error) => {

                });

            },
            //生成护工合同
            regenerateNursingWorkerContract(id){
                const h = this.$createElement;
                var text = '您确定重新生成护工合同吗？'
                this.$msgbox({
                    title: "",
                    type: "warning",
                    customClass: "v-back-pass",
                    message: h("p", null, [
                        h(
                            "p",
                            { style: "font-weight: 400; font-size: 14px; margin-bottom: 10px" },
                            text
                        )
                    ]),
                    showCancelButton: true,
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    beforeClose: (action, instance, done) => {
                        if (action === "confirm") {
                            regenerateNursingWorkerContract({ id:id }).then((response) => {
                                if (response.code == 200) {
                                    this.msgSuccess("护工合同生成成功");
                                } else {
                                    this.$message.error(response.msg);
                                }
                                done();
                            }).catch((error) => {
                                done();
                                this.$message.error("请刷新页面");
                            });
                        } else {
                            done();
                        }
                    },
                });

            },
            //生成合同
            regenerateContract(){
                const h = this.$createElement;
                var text = '您确定重新生成合同吗？'
                this.$msgbox({
                    title: "",
                    type: "warning",
                    customClass: "v-back-pass",
                    message: h("p", null, [
                        h(
                            "p",
                            { style: "font-weight: 400; font-size: 14px; margin-bottom: 10px" },
                            text
                        )
                    ]),
                    showCancelButton: true,
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    beforeClose: (action, instance, done) => {
                        if (action === "confirm") {
                            regenerateContract({ escort_id: this.$route.query.id }).then((response) => {
                                if (response.code == 200) {
                                    this.msgSuccess("合同生成成功");
                                } else {
                                    this.$message.error(response.msg);
                                }
                                done();
                            }).catch((error) => {
                                done();
                            });
                        } else {
                            done();
                        }
                    },
                });

            },
            //修改患者姓名
            updateEscortInfo(){
                if(!this.form.patient.truename){
                    this.$message.error('请输入患者姓名');
                    return
                }
                const h = this.$createElement;
                var text = '您确定要患者姓名吗？'
                this.$msgbox({
                    title: "",
                    type: "warning",
                    customClass: "v-back-pass",
                    message: h("p", null, [
                        h(
                            "p",
                            { style: "font-weight: 400; font-size: 14px; margin-bottom: 10px" },
                            text
                        )
                    ]),
                    showCancelButton: true,
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    beforeClose: (action, instance, done) => {
                        if (action === "confirm") {
                            escortUpdateEscortInfo({
                                escort_id:this.$route.query.id,
                                truename:this.form.patient.truename
                            }).then((response) => {
                                if (response.code == 200) {
                                    this.msgSuccess("修改成功");
                                } else {
                                    this.$message.error(response.msg);
                                }
                                done();
                            }).catch((error) => {
                                done();
                            });
                        } else {
                            done();
                        }
                    },
                });

            },
            getList(){
                this.queryParams.escort_id = this.$route.query.id
                orderEscortOptionLog(this.queryParams).then((response) => {
                    if (response.code == 200) {
                        this.tableData = response.data;
                        this.total = Number(response.data.count)
                    } else {
                        this.$message.error(response.msg);
                    }
                }).catch((error) => {

                });
            },
            extension_status_name(type){
                if(type==2){
                    return '订单已转科'
                }else if(type==3){
                    return '待转科确认'
                }else if(type==4){
                    return '转科退回'
                }
            },
            dialogShow(type){
                this.dialogType = type
                if(type==1){
                    this.dialogTitle='订单实缴金额说明'
                }else if(type==2){
                    this.dialogTitle='护工劳务费说明'
                }else if(type==3){
                    this.dialogTitle='订单应支付金额说明'
                }else if(type==4){
                    this.dialogTitle='患者支付金额说明'
                }else if(type==5){
                    this.dialogTitle='退款金额说明'
                }else if(type==6){
                    this.dialogTitle='主管录入护理服务费说明'
                }

                this.dialogTips = true
            },
            handleClose(){
                this.dialogTips = false
            },
            refundReason(type){
                if(type==0){
                    return '其他'
                }else if(type==1){
                    return '患者提前出院'
                }else if(type==2){
                    return '护工提前下活'
                }
            },
            refundMode(type){
                if(type==3){
                    return '线上退款原路返回'
                }else{
                    return '线下退款'
                }
            },
            refundRate(type){
                if(type==2){
                    return '退款中'
                }else if(type==3){
                    return '退款成功'
                }else if(type==4){
                    return '退款完成'
                }else if(type==5){
                    return '退款失败'
                }
            },
            escortTypeName(type){
                var name = '--';
                if(type=='mp'){
                    name='扫二维码';
                }else if(type=='web'){
                    name='电脑网站支付';
                }else if(type=='wap'){
                    name='扫二维码';
                }else if(type=='miniapp'){
                    name='小程序支付';
                }else if(type=='offline'){
                    name='线下支付';
                }else if(type=='pos'){
                    name='扫收款码';
                }
                return name
            },
            paymentName(payment,type){
                var name = '--';
                if(payment==1){
                    name='现金';
                }else if(payment==2){
                    name='支付宝';
                }else if(payment==3){
                    name='微信';
                }
                return name
            },
            salary_statusName(type){
                var arr=['','审核中','再次审核','审核驳回','待发放','发放失败','已发放']
                return arr[type]
            },
            typeName(row){
                var escort_status = row.escort_status;
                var extension_status = row.extension_status;
                var escort_pay_status = row.escort_pay_status;
                var str=''
                if(escort_status==10){

                    str+='已完成'
                    if(extension_status==1){
                        str+='/已展期'
                    }
                    if(extension_status==2){
                        str+='/已转科'
                    }
                    if(escort_pay_status==4){
                        str+='/退款完成'
                    }
                    if(escort_pay_status==2||escort_pay_status==3){
                        str+='/退款中'
                    }
                    if(escort_pay_status==5){
                        str+='/退款失败'
                    }
                    return str
                }else if(escort_status==7){
                    str+='服务中'
                    if(extension_status==1){
                        str+='/已展期'
                    }
                    if(extension_status==2){
                        str+='/已转科'
                    }
                    if(escort_pay_status==4){
                        str+='/退款完成'
                    }
                    if(escort_pay_status==2||escort_pay_status==3){
                        str+='/退款中'
                    }
                    if(escort_pay_status==5){
                        str+='/退款失败'
                    }
                    return str
                }else if(escort_status==6){
                    return '护工待分配'
                }else if(escort_status==5){
                    return '待支付'
                }else if(escort_status==4){
                    return '待支付'
                }else if(escort_status==3){
                    return '合同待签署'
                }else if(escort_status==2){
                    return '退回修改'
                }else if(escort_status==1){
                    return '待患者确认'
                }
            },
        },
        created() {
            //护工合同生成权限
            if(checkPermi(["regenerateNursingWorkerContract"])){
                this.regenerateNursingWorkerContractStyle = true
            }else{
                this.regenerateNursingWorkerContractStyle = false
            }
            //修改患者姓名权限

            if(checkPermi(["updatePatientName"])){
                this.updatePatientName = true
            }else{
                this.updatePatientName = false
            }
            this.init();
        },
    };
</script>
<style>
    .table th,.table td{ width: 10%;}
    .tableNoW th,.tableNoW td{ width: auto !important; position: relative;}
    td.el-table__cell:hover,.el-table__row:hover{background:none !important;}
    td.el-table__cell{transition:none !important;background:none !important;}
</style>
<style scoped>
    .table >>> .el-descriptions__header .el-descriptions__extra{ flex: 1; margin-left: 20px;}
    .agreement{ width: 25px; height: 27px;background: url('../../../assets/agreement.png') no-repeat; background-size: 100%; position: absolute; top: -14px; right: 25px; cursor: pointer;}
    .generate{ width: 25px; height: 25px;background: url('../../../assets/generate.png') no-repeat; background-size: 85% 100%; position: absolute; top: -14px; right: -10px; cursor: pointer;}


    .question{ position: relative;}
    .dialogTips{border: 1px solid #e6ebf5; padding: 15px; position: relative; top: -15px;}
    .headerIcon{ color:#ffba00; cursor: pointer; position: relative; font-size: 18px; position: absolute; top: -8px; right: -8px;}
    .borderBlock{ border: 1px solid #e6ebf5; margin-top: 20px; padding:15px;box-shadow: 0 1px 2px rgb(150 150 150 / 30%); border-radius: 10px;}
    .margin-top{ margin-top: 20px;}
    .app-container{ padding: 20px;}

    .operationRecord{margin: 20px 0 0;}
    .operationRecord .title{ font-size: 16px; font-weight: bold; }
    .operationRecord .list { margin: 20px 0 0 10px; padding: 0}
    .operationRecord .list li{ border-left: 1px solid #e4e4e4; list-style: none; padding:0 0 30px 15px; position: relative}
    .operationRecord .list li:after {content: '';width: 15px;height: 15px; background: #FFFFFF; border: 2px solid #498aff; position: absolute; top: 0; left:-7.5px; border-radius: 15px;}
    .operationRecord .list li span{ display: block; color: #333333; padding-bottom: 10px}
    .operationRecord .list li span:first-child{font-weight: bold;}
    .operationRecord .list li:last-child{border-left:none;}

    .borderBlock .carerList .carerTitle{ padding: 0 15px; margin-bottom: 15px; line-height: 45px; background: #f5f7fa; color: #000000;}
    .borderBlock .carerList .carerTitle .type{vertical-align:middle; display: inline-block; height: 35px; line-height: 35px; padding: 0 25px; margin: 5px 20px; border-radius: 5px; background: #f59a23; color: #FFF;}
    .borderBlock .carerList .carerTitle .line{ padding: 0 10px;}
    .borderBlock .carerList .cell{ text-align: center;}
    .borderBlock .carerList .margin-top a{ color: #0000ff; text-decoration: underline;}

    .typeBlock>div{ display: inline-block; min-height: 530px; margin-right:15px ; vertical-align: text-top;}
    .refund{ width: 40%; border: 1px solid #e6ebf5; margin-top: 20px; padding:15px;box-shadow: 0 1px 2px rgb(150 150 150 / 30%); border-radius: 10px;}
    .refund .title{ font-size: 16px; background: #555555; color: #FFFFFF; height: 50px; line-height: 50px; text-align: center; font-weight: bold; }
    .refund .list{ padding: 15px 0;}
    .refund .list>div{ padding: 0 10px; line-height: 45px; font-weight: bold;border-bottom: 1px solid #e6ebf5;}
    .refund .list>div>.right{ float: right; font-weight: normal;}
    .refund .list>div>.size{ font-size: 14px; font-weight: normal;}
    .refund .list .explain .info{ font-weight: normal;}

    .period{ width: 40%; border: 1px solid #e6ebf5; margin-top: 20px; padding:15px;box-shadow: 0 1px 2px rgb(150 150 150 / 30%); border-radius: 10px;}
    .period .title{ font-size: 16px; background: #80ffba; color: #000; height: 50px; line-height: 50px; text-align: center; font-weight: bold; }
    .period .list{ padding: 15px 0;}
    .period .list>div{ padding: 0 10px; line-height: 45px; font-weight: bold;border-bottom: 1px solid #e6ebf5;}
    .period .list>div>.right{ float: right; font-weight: normal;}

    .turnSection{ width: 40%; border: 1px solid #e6ebf5; margin-top: 20px; padding:15px;box-shadow: 0 1px 2px rgb(150 150 150 / 30%); border-radius: 10px;}
    .turnSection .title{ font-size: 16px; background: #ffff80; color: #000; height: 50px; line-height: 50px; text-align: center; font-weight: bold; }
    .turnSection .list{ padding: 15px 0;}
    .turnSection .list>div{ padding: 0 10px; line-height: 45px; font-weight: bold;border-bottom: 1px solid #e6ebf5;}
    .turnSection .list>div>.right{ float: right; font-weight: normal;}


    .allRelationOrder{margin: 20px 0 0;}
    .allRelationOrder .title{ font-size: 16px; font-weight: bold; }
    .allRelationOrder .list{ padding-top: 15px ;}
    .allRelationOrder .list span{ line-height: 40px; padding: 0 10px; color: #498aff; cursor: pointer; display: block;border-bottom: 1px solid #e6ebf5;}

    .operationJournal .title{ font-size: 16px; font-weight: bold; padding-bottom: 15px; }
    .operationJournal .page{ padding: 15px; text-align: right;}
</style>